<?php

function smarty_function_attribute_search($params)
{
	global $smarty;
	
	if ($params['group']!='raspred') {
		return '';
	}
	
	$tid = 'raspred_attributes';
	
	$attrs = array(
		'lines_num' => array('name'=>'Линий/позиций'),
		'control' => array('name'=>'Управление'),
		'passage' => array('name'=>'Условный проход'),
		'joining' => array('name'=>'Присоединение')
	);
		
	$currentVals = cf\param::exist('a') ? cf\param::get('a') : array();
	foreach ($attrs as $id => &$a) {
		$a['values'] = cf\query2vector("SELECT DISTINCT TRIM($id) AS v FROM $tid ORDER BY v");
		$a['current'] = array_key_exists($id,$currentVals) ? $currentVals[$id] : '';
	}
	
	$smarty->assign('attributes',$attrs);
	
	return $smarty->fetch("attribute_search.tpl");
}

?>